package itheima.com.zuoye.d03;


import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        Student s = new Student("艾大海", "A230602820", "男", 25, "大专以下", "永州职业技术学员");
        Student s2 = new Student("曹少坤", "A230601537", "男", 23, "本科及以上", "");
        Student s3 = new Student("陈橙", "A230600767", "男", 21, "大专 ", "湖南软件职业学员");
        Student s4 = new Student("陈福", "A230601913", "男", 21, "大专", "湖南机电职业技术学员");
        Student s5 = new Student("陈美鹃", "A230600523", "男", 25, "本科及以上", "");
        Student s6 = new Student("陈鑫", "A230601837", "男", 21, "大专以下", "长查民政职业技术学员");
        Student s7 = new Student("陈泳名", "A230601852", "男", 23, "大专", "湖南信息职业技术学员");
        Student s8 = new Student("邓灿宇", "A230601109", "男", 22, "大专", "");
        Student s9 = new Student("邓明", "A230601830", "男", 21, "大专以下", "");
        Student s10 = new Student("付云杰", "A230603250", "男", 22, "大专", "湘西名族职业技术学员");
        Student s11 = new Student("胡振宇", "A230601217", "男", 25, "本科及以上", "湖南涉外经济学员");
        Student s12 = new Student("黄永麒", "A210302017", "男", 23, "本科及以上", "湖南涉外经济学员");
// 创建集合，添加学生数据
        ArrayList<Student> list = new ArrayList<>();
        list.add(s);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);
        list.add(s6);
        list.add(s7);
        list.add(s8);
        list.add(s9);
        list.add(s10);
        list.add(s11);
        list.add(s12);
        // 前端请求数据
        String url = "https://tlias.itcast.cn/tz/classStudentList?name=陈&age=21";

        String[] params = url.split("\\?")[1].split("&");
        String name = params[0].split("=")[1];
        String ageStr = params[1].split("=")[1];
        int age = Integer.parseInt(ageStr); // 将 String 类型的年龄转换为 int 类型

// 遍历集合，查找符合条件的学生
        for (Student student : list) {
            if (student.getName().contains(name) && student.getAge() == age) {
                System.out.println("符合条件的学生信息如下：");
                System.out.println(student.getName() + student.getAge());
            }
        }
    }
// 从以上的字符串中，获取"陈"和22，然后从集合中把满足条件的学生信息在控制台打印出来！！！
//找到姓名为邓 和年龄为21的所有学生
//注意获取的22为String类型需要转换成int类型才能查找 (自己想办法解决)
// 【此处完成代码】！！！
}


